package com.mask.chapter02;

import java.math.BigDecimal;

/**
 * @author hx
 * @since 2021/12/16 3:23 下午
 */

public class Book implements Comparable<Book>{
    private String bookId;
    private String bookName;
    private String author;
    private Integer typeId;
    private Double price;
    private String isbn;
    private String publishing;
    private String introduce;
    private Integer status;

    public Book() {
    }

    public Book(String bookId, String bookName, String author, Integer typeId, Double price, String isbn, String publishing, String introduce, Integer status) {
        this.bookId = bookId;
        this.bookName = bookName;
        this.author = author;
        this.typeId = typeId;
        this.price = price;
        this.isbn = isbn;
        this.publishing = publishing;
        this.introduce = introduce;
        this.status = status;
    }

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Integer getTypeId() {
        return typeId;
    }

    public void setTypeId(Integer typeId) {
        this.typeId = typeId;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public String getPublishing() {
        return publishing;
    }

    public void setPublishing(String publishing) {
        this.publishing = publishing;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (bookId != null ? !bookId.equals(book.bookId) : book.bookId != null) return false;
        if (bookName != null ? !bookName.equals(book.bookName) : book.bookName != null) return false;
        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (typeId != null ? !typeId.equals(book.typeId) : book.typeId != null) return false;
        if (price != null ? !price.equals(book.price) : book.price != null) return false;
        if (isbn != null ? !isbn.equals(book.isbn) : book.isbn != null) return false;
        if (publishing != null ? !publishing.equals(book.publishing) : book.publishing != null) return false;
        if (introduce != null ? !introduce.equals(book.introduce) : book.introduce != null) return false;
        return status != null ? status.equals(book.status) : book.status == null;
    }

    @Override
    public int hashCode() {
        int result = bookId != null ? bookId.hashCode() : 0;
        result = 31 * result + (bookName != null ? bookName.hashCode() : 0);
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + (typeId != null ? typeId.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (isbn != null ? isbn.hashCode() : 0);
        result = 31 * result + (publishing != null ? publishing.hashCode() : 0);
        result = 31 * result + (introduce != null ? introduce.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookId='" + bookId + '\'' +
                ", bookName='" + bookName + '\'' +
                ", author='" + author + '\'' +
                ", typeId=" + typeId +
                ", price=" + price +
                ", isbn='" + isbn + '\'' +
                ", publishing='" + publishing + '\'' +
                ", introduce='" + introduce + '\'' +
                ", status=" + status +
                '}';
    }

    @Override
    public int compareTo(Book b1) {
        return this.bookId.compareTo(b1.getBookId());
    }
}
